package com.winenine999.admin.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.winenine999.service.ISyauthorityService;

@Controller
@RequestMapping(value="/home")
public class HomeController {
	@Autowired
	private ISyauthorityService syauthorityService;

	/**
	 * 进入主页面main.jsp
	 * @return
	 */
	@RequestMapping(value="/main",method=RequestMethod.GET)
	public String main(Model model,Integer syuserId){
		model.addAttribute("syuserId", syuserId);
		return "common/main";
	}
	@RequestMapping(value="/index",method=RequestMethod.GET)
	public String index(){
		
		return "common/index_tea";
	}
	@RequestMapping(value="/head",method=RequestMethod.GET)
	public String head(){
		
		return "common/head";
	}
	@RequestMapping(value="/left",method=RequestMethod.GET)
	public String left(){
		
		return "common/left";
	}
	/**
	 * 
	 * @return
	 */
	@RequestMapping(value="/menu",method=RequestMethod.POST)
	@ResponseBody
	public List<Map<String,Object>>menu(Integer syuserId){
		//没有id传过来，说明是从权限管理页面进入的（懒的再写一个全查的就放一起）
		List<Map<String,Object>> maps;
		if(syuserId!=null){
		 maps=syauthorityService.findPermissionsByUserId(syuserId);
		}else{
			
		 maps=syauthorityService.findAllSyauthoritys();
		}
		return maps;
	}
}
